<!DOCTYPE html>
<html>
<head> 
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1, user-scalable=no">
    <title>玩AR游戏 赢虎扑好礼</title>
    <link rel="stylesheet" type="text/css" media="screen" href="/static/css/base.css" />
    <link rel="stylesheet" type="text/css" media="screen" href="/static/summary/animate.min.css" />
    <link rel="stylesheet" type="text/css" media="screen" href="/static/css/swiper-3.3.1.min.css" />
    <link rel="stylesheet" type="text/css" media="screen" href="/static/css/vr.css" />

    <script src="/static/js/jquery.min.js"></script>
    <script src="/static/js/js.js"></script>
    <script src="/static/js/mod.js"></script>
    <script src="/static/summary/swiper-3.4.1.min.js"></script>
    <script src="/static/summary/swiper.animate1.0.2.min.js"></script>

</head>
<body>
    <section class="mod-box"> 
         <section class="img-box">
             
         </section>
        <section class="a-list">
            <a class="help">帮TA一把 (<span class="help-time">{$left_times}</span>)</a>
            <a href="http://a.mlinks.cc/Aagn">我也要领养</a>
        </section>
       
        <dl class="rank-list"></dl>
        <a href="http://a.mlinks.cc/Aagn">
            <img class="footer-img" src="{$staticHost}/static/images/vr/text.png">
        </a>
        <section class="masklayer" style="display: ;">
            <div class="gift-box">
                <img src="/static/images/vr/01.png">
                <h3 class="title">皱成一团的盒子</h3>
                <p class="text-box">
                    <span class="color-red" id="petname">宠物名称</span>目光炯炯的看着你，而后不知道从哪个角落里衔出了一个纸团一样的盒子……突然，你的脑海中传出一个柔柔的声音：<br/>
                    谢谢你满足我的愿望，请一定要收下我的礼物！
                </p>
                <div class=a-list>
                    <a class="open">打开礼物</a>
                </div>
            </div>
        </section>
    </section>
    <!-- 盒子 -->
    <script id="pet" type="text/html">
        <img src="{$staticHost}/static/images/vr/bird.png">
        <p>
            我的小宠物【<%=result.nickname%>】{$tipsString}
        </p>
    </script>
    <script id="gameRank" type="text/html">
       <dt>累计帮助</dt>
       <% for(var i = 0; i < result.carelist.length; i++) { %>
            <dd>
                <img src="<%if(result.carelist[i].from_user.header){%><%=result.carelist[i].from_user.header%><%}else{%>/static/images/4.jpg<%}%>">
                <span class="name"><%=result.carelist[i].from_user.nickname%></span>
                <span class="num"><%=result.carelist[i].care_count%>次</span>
            </dd>
        <%}%>
    </script>
    <!-- 排行榜模板 -->
    <div id="tips"></div>
</body>
 <script>
    var to_uid = '{$to_uid}'
    var monster_id ='{$monster_id}';
    $.get('{$appHost}/gameWeb/getCareList',{'uid':to_uid,'page':1,'limit':10}, renderHome);
    function renderHome(data) {
        data = JSON.parse(data);
        var html = template('gameRank', data);
        $('.rank-list').html(html);
        var screenHeight = document.body.scrollHeight;
    }
    // 排行
    $.get('{$appHost}/gameWeb/getMonsterInfo',{'id':monster_id}, petHome);
    function petHome(data) {
        data = JSON.parse(data);
        $("#petname").html(data.result.nickname)
        var html = template('pet', data);
        $('.img-box').html(html);
        var time = $('.help-time').html()
        if(time == 0) {
           $(".help").addClass('red')
           $(".help").unbind()
           $(".help").html('明天再来')
        }
    }
    // 宠物信息
    $(".help").click(function(){
         $.post("{$appHost}/gameWeb/careMonster",{'monster_id':monster_id}, function(data, error) {
            data = JSON.parse(data);
            var info = data.result.giftInfo;
            $('.help-time').html(data.result.left_times)
            
            $("#tips").html('{$tostString}')
            $("#tips").show();

            $("body").css("overflow","hidden")
            setTimeout(function(){ 
                $("#tips").hide();
                $("body").css("overflow","auto")
            }, 2000);
            setTimeout(function(){ 
                $(".masklayer").fadeIn();

                $(".open").click(function(){
                    if(info.name=='空'&&info.giftType==2){
                        $('.text-box').html('礼物被TA 弄丢了 /(ㄒoㄒ)/~~')
                        setTimeout(function(){ 
                         $(".masklayer").fadeOut();
                        },2500);
                    }else if(info.name!='空'&&info.giftType==2){
                        window.location.href='ARcard?uid='+to_uid;
                    }else{
                        window.location.href='ARaddress'
                    }
                })
                

            }, 4000);
            if(data.result.left_times==0){
                $(".help").addClass('red')
                $(".help").unbind()
                $(".help").html('明天再来')
                return
            }
        })
    })
    // 帮助
</script>
{template 'show/web-footer'}